package cn.stalk.compare.result;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 整理后分类的比较信息
 */
public class ComparisonResult<T> {

    private List<Object> duplicateSourceKeys = new ArrayList<>();
    private List<Object> duplicateTargetKeys = new ArrayList<>();

    // source余下的
    private Map<Object, List<T>> remainingSources = new HashMap<>();
    // target余下的
    private Map<Object, List<T>> remainingTargets = new HashMap<>();
    // 变化的
    private List<DifferencePair<T>> changed = new ArrayList<>();
    // 相同的
    private List<ComparisonPair<T>> sames = new ArrayList<>();
    // 一对多无效比较
    private List<ComparisonPair<List<T>>> invalid = new ArrayList<>();

    /**
     * 是否有差异（不检查无效比较）
     */
    public boolean hasDifference() {
        return !(remainingSources.isEmpty() && remainingTargets.isEmpty() && changed.isEmpty());
    }

    /**
     * 是否有无效比较
     */
    public boolean hasInvalid() {
        return !invalid.isEmpty();
    }

    public List<Object> getDuplicateTargetKeys() {
        return duplicateTargetKeys;
    }

    public List<Object> getDuplicateSourceKeys() {
        return duplicateSourceKeys;
    }

    public Map<Object, List<T>> getRemainingTargets() {
        return remainingTargets;
    }

    public Map<Object, List<T>> getRemainingSources() {
        return remainingSources;
    }

    public List<DifferencePair<T>> getChanged() {
        return changed;
    }

    public List<ComparisonPair<T>> getSames() {
        return sames;
    }

    public List<ComparisonPair<List<T>>> getInvalid() {
        return invalid;
    }
}
